package com.soft.hwx.scdapp;

import android.util.Log;

import java.math.BigDecimal;

public class StrHelper {


    public static String strCovJwd(String str)
    {
        if(str.equals("")){
            return "0";
        }
        try{
            String subJd = str.substring(0, str.length() - 1);
            //System.out.println(substring);
            String[] splitJd = subJd.split("\\.");//以点号分割
            //Log.d("MainActivity", "整数"+splitJd[0]);

            String jdf = splitJd[0].substring(splitJd[0].length() -2,splitJd[0].length());   //截取后两位
            //Log.d("MainActivity", "整数后两位"+jdf);

            String jdd = splitJd[0].substring(0,splitJd[0].length()-2);   //截掉后两位
            //Log.d("MainActivity", "整数截掉后两位"+jdd);

            //Log.d("MainActivity", "小数点"+splitJd[1]);
            BigDecimal bdjd1 = new BigDecimal(splitJd[1]);

            //Log.d("MainActivity", "小数转换后的值"+bdjd1.divide(new BigDecimal(100)).multiply(new BigDecimal(60)).toString());

            //取小数转换后的前两位
            String jdm = bdjd1.divide(new BigDecimal(100)).multiply(new BigDecimal(60)).toString();
            jdm = jdm.substring(0,2);

            //Log.d("MainActivity", "转换后的最终值"+jdd+"°"+jdf+"'"+jdm+"''");

            return jdd+"°"+jdf+"'"+jdm+"''";
        } catch (Exception e) {

        }
            return "0";
    }

    /**
     * 字符串转化成为16进制字符串
     * @param s
     * @return
     */
    public static byte[] strTo16(String s) {
        String str = "";
        for (int i = 0; i < s.length(); i++) {
            int ch = (int) s.charAt(i);
            String s4 = Integer.toHexString(ch);
            str = str + s4;
        }
        return str.getBytes();
    }

}




